package com.ygqh.baby.controller.admin;


import com.ygqh.baby.ao.Message;
import com.ygqh.baby.ao.QueryInfo;
import com.ygqh.baby.ao.ResultSet;
import com.ygqh.baby.po.YgAccountDetail;
import com.ygqh.baby.service.YgAccountDetailService;
import com.ygqh.baby.service.YgUserBalanceService;
import com.ygqh.baby.shiro.utils.SessionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;

@Controller
@RequestMapping("/admin/uerBalance")
public class UserBalanceController extends BaseController<Object, Long>{

	 @Autowired
	 private YgUserBalanceService userBalanceService;
	 @Autowired
	private YgAccountDetailService accountDetailService;


	/**
	 * 充值
	 * @param phone
	 * @param price
	 * @param remark
	 * @return
	 */
	@RequestMapping("recharge")
	@ResponseBody
	public Message recharge(String phone,BigDecimal price,String remark) {
		return userBalanceService.recharge(phone,price, remark,SessionUtil.getCurrentUser().getTrueName());
	}



	/**
	 * 查找充值记录
	 * @param queryInfo
	 * @return
	 */
	@RequestMapping("searchDetailByUser")
	@ResponseBody
	public Map<String, Object> searchDetailByUser(QueryInfo queryInfo,String  username,String source,Date startDate,Date endDate,String remark){
		ResultSet<YgAccountDetail> resultSet = accountDetailService.searchDetailByUser(queryInfo,username, source,startDate,endDate,remark);
		return resultSet.toDatatables(null,resultSet.getExt()+"");

	}


}
